class Solution {
    public boolean validPalindrome(String s) {
        return valid(s, 0, s.length() - 1, true);
    }
    public boolean valid(String s, int start, int end, boolean canDelete) {
        for (int i = start, j = end; i < j; i++, j--) {
            if (s.charAt(i) != s.charAt(j)) {
                if (canDelete) {
                    return valid(s, i + 1, j, false) || valid(s, i, j - 1, false);
                }
                return false;
            }
        }
        return true;
    }
}
